﻿<%@ Page Title="" Language="C#" MasterPageFile="~/FilStartUps.Master" AutoEventWireup="true"
    CodeBehind="ForgotPassword.aspx.cs" Inherits="FilStartUps.ForgotPassword" %>

<%@ Register Src="Controls/FilStartUps_PageNav.ascx" TagName="FilStartUps_PageNav"
    TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainNav" runat="server">
    <uc1:FilStartUps_PageNav ID="FilStartUps_PageNav1" runat="server" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="BodyHolder" runat="server">
   <script src="Script/jquery.form.js" type="text/javascript"></script>
    <script src="Script/jquery.validation.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).ready(function () {
               $('#form1').validate({
                errorClass: "error_login",
                rules: {
                   <%=txtemail.UniqueID  %> : "required",
                  <%= ddlsecurityquestion.UniqueID  %> : {
                        required: true
                    },
                  <%= txtsecretanswer.UniqueID  %> : "required"
                   
                },
                messages: {
                    <%=txtemail.UniqueID  %>: "*",
                    <%= txtsecretanswer.UniqueID  %>: "*",
                    <%= ddlsecurityquestion.UniqueID  %>: "Please select an option"
                },
                submitHandler: function () {
                    submit_login();
                }
            });
        });

            function submit_login() {
            $('#form1').ajaxSubmit(function () {

                $('#validation_error').addClass('success').html('<img src="../Content/images/ajax-loader.gif"></img>');

                var parameters = ["email", $('<%=txtemail.UniqueID  %>').val(), "secretquestion", $('<%=ddlsecurityquestion.UniqueID  %>').val(), "secretanswer", $('<%=txtsecretanswer.ClientID %>').val()];
                var paramList = '';
                if (parameters.length > 0) {
                    for (var i = 0; i < parameters.length; i += 2) {
                        if (paramList.length > 0) paramList += ',';
                        paramList += '"' + parameters[i] + '":"' + parameters[i + 1] + '"';
                    }
                }
                paramList = '{' + paramList + '}';

                $.ajax({
                    type: "POST",
                    url: "../FilStartUps_WebService.asmx/ForgotPassword",
                    data: paramList,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (msg) {
                        if (msg.d == true) {
                            $('#validation_error').html('');
                            $('#validation_error').text('An Email Message has been sent to you');
                        }
                        else {

                            $('#validation_error').removeClass('success');
                            $('#validation_error').addClass('error').text('Invalid Credentials');
                        }
                    }
                })
            })
        }
   </script>

    <div style="margin-top: 50px">
        <fieldset style="width:700px">
            <legend>Forgot Password</legend>
            <asp:ScriptManager ID="sm" EnablePageMethods="true" runat="server">
                <Services>
                    <asp:ServiceReference Path="~/FilStartUps_WebService.asmx" />
                </Services>
            </asp:ScriptManager>
            <div id="validation_error">
            </div>
            <table width="100%">
                <tr>
                    <td>
                        <asp:Label runat="server" ID="lbtxtemail">Email Address:</asp:Label>
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="txtemail"></asp:TextBox>
                      <%--   <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic"
                            ErrorMessage="*" ControlToValidate="txtemail"></asp:RequiredFieldValidator>--%>
                    </td>
                </tr>
                <tr>
                    <td>
                        Secret Question:
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlsecurityquestion" runat="server">
                            <asp:ListItem Text="Choose Question" Value=""></asp:ListItem>
                            <asp:ListItem Value="What is the name of your favorite sports team?">What is the name of your favorite sports team?</asp:ListItem>
                            <asp:ListItem Value="What is the name of your favorite book?">What is the name of your favorite book?</asp:ListItem>
                            <asp:ListItem Value="What was your first pet's name?">What was your first pet's name?</asp:ListItem>
                            <asp:ListItem Value="What is the name of the street on which you grew up?">What is the name of the street on which you grew up?</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>
                        Secret Answer:
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="txtsecretanswer"></asp:TextBox>
                         <%-- <asp:RequiredFieldValidator runat="server" Display="Dynamic" ErrorMessage="*" ControlToValidate="txtsecretanswer"></asp:RequiredFieldValidator>--%>
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td>
                        <asp:Button runat="server" ID="btnSend" CssClass="btn" Text="Send"  /><%--OnClick="btnSend_Click"--%>
                        <asp:Button runat="server" ID="btnCancel" CssClass="btn" Text="Cancel" />
                    </td>
                </tr>
            </table>
        </fieldset>
    </div>

</asp:Content>
